import { Event_Name, MyEvnetHandler } from "./event_mgr";
import { EventTool } from "./event_tool";


export default class EventManager extends EventTool {
    private static _ins: EventManager = null;

    public static get Instance(): EventManager {
        if (!this._ins) {
            this._ins = new EventManager();
        }
        return this._ins;
    }

    public emit(eventType: Event_Name, ...params) {
        this.fireEvent(eventType, ...params)
    }

    public on(eventType: Event_Name, handler: MyEvnetHandler) {
        this.addEventListener(eventType, handler);
    }

    public off(eventType: Event_Name, handler: MyEvnetHandler) {
        this.removeEventListener(eventType, handler);
    }

    public clearAll() {
        this.clearEventListeners();
    }
}